/**
 * Copyright(c) Hainan eKing Technology co., LTD
 *
 * @date 2013年8月13日
 * 	
 * Original Author: 郑兴(zhengxing)
 *
 * ChangeLog
 *
 */
package com.hnas.sys.service.system.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.springframework.security.core.GrantedAuthority;

import com.hnas.sys.domain.ResourceStatus;

/**
 * @author 郑兴(zhengxing)
 *
 */
public class DTOAuthority implements GrantedAuthority,Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -4555341582721543780L;
	
	public static final String ROLE_SUPPLIER_NAME = "供应商";

	private long id;
    private String name;
    private String description;
    private ResourceStatus status;
    private String resourceIDs;
    private long[] resourceIds;
    private List<DTOAuthorityResource> dtoAuthorityResources = new ArrayList<DTOAuthorityResource>();
    
	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}
	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}
	/**
	 * @return the status
	 */
	public ResourceStatus getStatus() {
		return status;
	}
	/**
	 * @param status the status to set
	 */
	public void setStatus(ResourceStatus status) {
		this.status = status;
	}
	/**
	 * @return the resourceIDs
	 */
	public String getResourceIDs() {
		return resourceIDs;
	}
	/**
	 * @param resourceIDs the resourceIDs to set
	 */
	public void setResourceIDs(String resourceIDs) {
		this.resourceIDs = resourceIDs;
	}

	/**
	 * @return the dtoAuthorityResources
	 */
	public List<DTOAuthorityResource> getDtoAuthorityResources() {
		return dtoAuthorityResources;
	}
	/**
	 * @param dtoAuthorityResources the dtoAuthorityResources to set
	 */
	public void setDtoAuthorityResources(
			List<DTOAuthorityResource> dtoAuthorityResources) {
		this.dtoAuthorityResources = dtoAuthorityResources;
	}
	/*
	 * (non-Javadoc)
	 * @see org.springframework.security.core.GrantedAuthority#getAuthority()
	 */
	public String getAuthority() {
		return "ROLE_" + id;
	}
	
	public boolean isValid(){
		return ResourceStatus.VALID.equals(this.status);
	}
	public long[] getResourceIds() {
		return resourceIds;
	}
	public void setResourceIds(long[] resourceIds) {
		this.resourceIds = resourceIds;
	}
	public void setId(long id) {
		this.id = id;
	}
}
